get_marginal_effects <- function(x = NULL){
fx_mean <- coef(x)
fx_se <- sqrt(diag(vcov(x)))
fx_hi <- fx_mean + 1.96 * fx_se
fx_lo <- fx_mean - 1.96 * fx_se
est_out <- data.frame(term = names(coef(x)),
estimate = fx_mean,
se = fx_se,
conf.high = fx_hi,
conf.low = fx_lo,
row.names = NULL)
est_out <- tibble(est_out)
return(est_out)
}
get_marginal_effects_interaction <- function(var, interaction_levels = levels(out$vote19), x = NULL){
var_coefs_idx <- which(grepl(var,names(x$coefficients)))
var_coefs_baseline_idx <- var_coefs_idx[1]
var_ceofs_int_inx <- var_coefs_idx[-1]
fx_mean <- c(x$coefficients[var_coefs_baseline_idx],
x$coefficients[var_coefs_baseline_idx] + x$coefficients[var_ceofs_int_inx])
fx_se <- c(sqrt(vcov(x)[var_coefs_baseline_idx, var_coefs_baseline_idx]),
sapply(1:length(var_ceofs_int_inx), function(i) sqrt(vcov(x)[var_coefs_baseline_idx, var_coefs_baseline_idx] + vcov(x)[var_ceofs_int_inx[i], var_ceofs_int_inx[i]] + vcov(x)[var_coefs_baseline_idx,var_ceofs_int_inx[i]])))
fx_hi <- fx_mean + 1.96 * fx_se
fx_lo <- fx_mean - 1.96 * fx_se
est_out <- data.frame(treatment = var,
levels = interaction_levels,
estimate = fx_mean,
se = fx_se,
hi = fx_hi,
lo = fx_lo,
row.names = NULL)
return(est_out)
}
baseline_out_income_guarantee_coefs <- baseline_out_income_guarantee %>%
map(~ get_marginal_effects(.x)) %>%
bind_rows(.id = "var") %>%
mutate(term = recode(term, lost_employmentTRUE = "Lost Employment",
income_guarantee_treatmentTRUE = "Gov. Support"))
# 1. onelawrich; taxSpendSelf; redistSelf (Aii)
outcome_vars <- c("redistSelf", "taxSpendSelf", "ideoOneLawRich", "ideoBHPSJjobForAll", "reasonForUnemployment", "riskPoverty", "riskUnemployment", "govtHandouts")
baseline_out_income_guarantee_coefs %>%
filter(var %in% c("ideoBHPSJjobForAll","taxSpendSelf", "redistSelf") & term == "Gov. Support") %>%
mutate(var = factor(var, levels = outcome_vars),
var = recode_factor(var, `ideoBHPSJjobForAll`= "jobsForAll")) %>%
ggplot(aes(x = estimate, xmin = conf.low, xmax = conf.high, y = var)) +
geom_point() +
geom_errorbarh(height = 0.001) +
geom_vline(xintercept = 0, linetype = 2) +
theme_bw() +
theme(axis.text = element_text(size = 12),
text = element_text(size = 12)) +
ylab("") +
xlab("Treatment effect") +
xlim(c(-1,1)) +
facet_wrap(~term)
ggsave("../generated_images/fe_baseline_ideo_vars.pdf", height = 5*.75, width = 10)
# Table
ns <- rbind(apply(attr(baseline_out_income_guarantee$redistSelf$model, "index"),2,function(x) length(unique(x))),
apply(attr(baseline_out_income_guarantee$taxSpendSelf$model, "index"),2,function(x) length(unique(x))),
apply(attr(baseline_out_income_guarantee$ideoBHPSJjobForAll$model, "index"),2,function(x) length(unique(x))))
n_obs <- c(length(baseline_out_income_guarantee$redistSelf$weights),
length(baseline_out_income_guarantee$taxSpendSelf$weights),
length(baseline_out_income_guarantee$ideoBHPSJjobForAll$weights))
sink("../generated_tex/fe_baseline_ideo_vars.tex")
m1 <- baseline_out_income_guarantee$redistSelf
m2 <- baseline_out_income_guarantee$taxSpendSelf
m3 <- baseline_out_income_guarantee$ideoBHPSJjobForAll
stargazer::stargazer(m1, m2, m3,
dep.var.labels.include = T,
dep.var.caption = "",
multicolumn = FALSE,
dep.var.labels = c("$redistSelf$", "$taxSpendSelf$", "$jobsForAll$"),
no.space = TRUE,
omit.stat = c("all"),
covariate.labels = c("$CovidLostEmployment$", "$CovidGovSupport$"),
float = FALSE,
add.lines = list(c("N respondents", ns[,1]),
c("N waves", ns[,2]),
c("N obs.", n_obs),
c("Ind. FEs", "Yes", "Yes", "Yes"),
c("Wave FEs", "Yes", "Yes", "Yes")))
sink()
# 2. RiskUnemployment and RiskPoverty (Aiii)
baseline_out_income_guarantee_coefs %>%
filter(var %in% c("riskPoverty", "riskUnemployment")) %>%
mutate(var = factor(var, levels = outcome_vars)) %>%
ggplot(aes(x = estimate, xmin = conf.low, xmax = conf.high, y = var)) +
geom_point() +
geom_errorbarh(height = 0.001) +
geom_vline(xintercept = 0, linetype = 2) +
theme_bw() +
ylab("") +
xlab("Treatment effect") +
xlim(c(-1,1)) +
facet_wrap(~term)
ggsave("../generated_images/fe_baseline_risk_vars.pdf", height = 2, width = 6)
# Table
ns <- rbind(apply(attr(baseline_out_income_guarantee$riskPoverty$model, "index"),2,function(x) length(unique(x))),
apply(attr(baseline_out_income_guarantee$riskUnemployment$model, "index"),2,function(x) length(unique(x))))
n_obs <- c(length(baseline_out_income_guarantee$riskPoverty$weights),
length(baseline_out_income_guarantee$riskUnemployment$weights))
sink("../generated_tex/fe_baseline_risk_vars.tex")
m1 <- baseline_out_income_guarantee$riskPoverty
m2 <- baseline_out_income_guarantee$riskUnemployment
stargazer::stargazer(m1, m2,
dep.var.labels.include = T,
dep.var.caption = "",
multicolumn = FALSE,
dep.var.labels = c("$riskPoverty$", "$riskUnemployment$"),
no.space = TRUE,
omit.stat = c("all"),
covariate.labels = c("$CovidLostEmployment$", "$CovidGovSupport$"),
float = FALSE,
add.lines = list(c("N respondents", ns[,1]),
c("N waves", ns[,2]),
c("N obs.", n_obs),
c("Ind. FEs", "Yes", "Yes", "Yes"),
c("Wave FEs", "Yes", "Yes", "Yes")))
sink()
# 3. govtHandouts and reasonForUnemployment (Deservingness)
baseline_out_income_guarantee_coefs %>%
filter(var %in% c("govtHandouts", "reasonForUnemployment")) %>%
mutate(var = factor(var, levels = outcome_vars)) %>%
ggplot(aes(x = estimate, xmin = conf.low, xmax = conf.high, y = var)) +
geom_point() +
geom_errorbarh(height = 0.001) +
geom_vline(xintercept = 0, linetype = 2) +
theme_bw() +
ylab("") +
xlab("Treatment effect") +
xlim(c(-1,1)) +
facet_wrap(~term)
ggsave("../generated_images/fe_baseline_deserving_vars.pdf", height = 4/2, width = 12)
### - Baseline spec = separating UC, furlough, self-employment
baseline_out_income_guarantee_separate_coefs <- baseline_out_income_guarantee_separate %>%
map(~ get_marginal_effects(.x)) %>%
#map(~ broom::tidy(.x,conf.int = TRUE)) %>%
bind_rows(.id = "var") %>%
mutate(term = recode(term, lost_employmentTRUE = "Lost Employment",
income_guarantee_covid_job_treatmentTRUE = "Furlough",
income_guarantee_covid_self_treatmentTRUE = "Self-employment",
income_guarantee_other_treatmentTRUE = "Universal Credit"))
# 4. onelawrich; taxSpendSelf; redistSelf (Bi)
baseline_out_income_guarantee_separate_coefs %>%
filter(var %in% c("ideoBHPSJjobForAll","taxSpendSelf", "redistSelf")) %>%
mutate(var = factor(var, levels = outcome_vars),
var = recode_factor(var, `ideoBHPSJjobForAll`= "jobsForAll")) %>%
ggplot(aes(x = estimate, xmin = conf.low, xmax = conf.high, y = var)) +
geom_point() +
geom_errorbarh(height = 0.001) +
geom_vline(xintercept = 0, linetype = 2) +
theme_bw() +
ylab("") +
xlab("Treatment effect") +
xlim(c(-1,1)) +
facet_wrap(~term, ncol = 2)
ggsave("../generated_images/fe_multi_treatment_ideo_vars.pdf", width = 6, height = 3)
# Table
ns <- rbind(apply(attr(baseline_out_income_guarantee_separate$redistSelf$model, "index"),2,function(x) length(unique(x))),
apply(attr(baseline_out_income_guarantee_separate$taxSpendSelf$model, "index"),2,function(x) length(unique(x))),
apply(attr(baseline_out_income_guarantee_separate$ideoBHPSJjobForAll$model, "index"),2,function(x) length(unique(x))))
n_obs <- c(length(baseline_out_income_guarantee_separate$redistSelf$weights),
length(baseline_out_income_guarantee_separate$taxSpendSelf$weights),
length(baseline_out_income_guarantee_separate$ideoBHPSJjobForAll$weights))
sink("../generated_tex/fe_multi_treatment_ideo_vars.tex")
m1 <- baseline_out_income_guarantee_separate$redistSelf
m2 <- baseline_out_income_guarantee_separate$taxSpendSelf
m3 <- baseline_out_income_guarantee_separate$ideoBHPSJjobForAll
stargazer::stargazer(m1,m2,m3,
dep.var.labels.include = T,
dep.var.caption = "",
multicolumn = FALSE,
dep.var.labels = c("$redistSelf$", "$taxSpendSelf$", "$jobsForAll$"),
no.space = TRUE,
omit.stat = c("all"),
covariate.labels = c("$CovidLostEmployment$", "$CovidFurlough$", "$CovidSelfEmployment$", "$CovidUniversalCredit$"),
float = FALSE,
add.lines = list(c("N respondents", ns[,1]),
c("N waves", ns[,2]),
c("N obs.", n_obs),
c("Ind. FEs", "Yes", "Yes", "Yes"),
c("Wave FEs", "Yes", "Yes", "Yes")))
sink()
# 5. govtHandouts and reasonForUnemployment (Deservingness)
baseline_out_income_guarantee_separate_coefs %>%
filter(var %in% c("govtHandouts", "reasonForUnemployment") ) %>%
mutate(var = factor(var, levels = outcome_vars)) %>%
ggplot(aes(x = estimate, xmin = conf.low, xmax = conf.high, y = var)) +
geom_point() +
geom_errorbarh(height = 0.001) +
geom_vline(xintercept = 0, linetype = 2) +
theme_bw() +
ylab("") +
xlab("Treatment effect") +
xlim(c(-1,1)) +
facet_wrap(~term, ncol = 2)
ggsave("../generated_images/fe_multi_treatment_deserving_vars.pdf", width = 6, height = 3)
# Table
ns <- rbind(apply(attr(baseline_out_income_guarantee_separate$govtHandouts$model, "index"),2,function(x) length(unique(x))),
apply(attr(baseline_out_income_guarantee_separate$reasonForUnemployment$model, "index"),2,function(x) length(unique(x))))
n_obs <- c(length(baseline_out_income_guarantee_separate$govtHandouts$weights),
length(baseline_out_income_guarantee_separate$reasonForUnemployment$weights))
sink("../generated_tex/fe_multi_treatment_deserving_vars.tex")
m1 <- baseline_out_income_guarantee_separate$govtHandouts
m2 <- baseline_out_income_guarantee_separate$reasonForUnemployment
stargazer::stargazer(m1, m2,
dep.var.labels.include = T,
dep.var.caption = "",
multicolumn = FALSE,
dep.var.labels = c("$govtHandouts$", "$reasonForUnemployment$"),
no.space = TRUE,
omit.stat = c("all"),
covariate.labels = c("$CovidLostEmployment$", "$CovidFurlough$", "$CovidSelfEmployment$", "$CovidUniversalCredit$"),
float = FALSE,
add.lines = list(c("N respondents", ns[,1]),
c("N waves", ns[,2]),
c("N obs.", n_obs),
c("Ind. FEs", "Yes", "Yes", "Yes"),
c("Wave FEs", "Yes", "Yes", "Yes")))
sink()
## - party interaction spec = separating UC, furlough, self-employment (might be slicing the data too thin)
party_out_income_guarantee_separate_coefs <- party_out_income_guarantee_separate %>%
map(~ lapply(c("income_guarantee_covid_job_treatment", "income_guarantee_covid_self_treatment", "income_guarantee_other_treatment"),
function(v)
get_marginal_effects_interaction(v, interaction_levels = levels(out$vote19), x = .x)) %>%
bind_rows) %>%
bind_rows(.id = "var") %>%
tibble() %>%
mutate(treatment = recode(treatment, "income_guarantee_covid_job_treatment" = "Furlough",
"income_guarantee_covid_self_treatment" = "Self-employment",
"income_guarantee_other_treatment" = "Universal Credit"))
# 6. Onelawrich; TaxSpendSelf; RedistSelf; ReasonforUnemployment (Bi)
party_out_income_guarantee_separate_coefs %>%
filter(var %in% c("ideoBHPSJjobForAll","taxSpendSelf", "redistSelf")) %>%
mutate(var = factor(var, levels = outcome_vars),
var = recode_factor(var, `ideoBHPSJjobForAll`= "jobsForAll")) %>%
ggplot(aes(y = var, x = estimate, xmin = lo, xmax = hi, col = levels, group = levels, linetype = levels)) +
geom_point(position = position_dodge(width = .5)) +
geom_errorbarh(height = 0.0001, position = position_dodge(width = .5)) +
facet_wrap(~ treatment, ncol = 4) +
geom_vline(xintercept = 0, linetype = 1) +
xlim(c(-1,1)) +
theme_bw() +
scale_color_manual("Party", values = c("black", "darkgrey", "lightgrey")) +
xlab("Treatment effect") +
labs(color  = "Party", linetype = "Party") +
ylab("")
ggsave("../generated_images/fe_by_party_by_treat.pdf", width = 6, height = 3)
# Table
ns <- rbind(apply(attr(party_out_income_guarantee_separate$redistSelf$model, "index"),2,function(x) length(unique(x))),
apply(attr(party_out_income_guarantee_separate$taxSpendSelf$model, "index"),2,function(x) length(unique(x))),
apply(attr(party_out_income_guarantee_separate$ideoBHPSJjobForAll$model, "index"),2,function(x) length(unique(x))))
n_obs <- c(length(party_out_income_guarantee_separate$redistSelf$weights),
length(party_out_income_guarantee_separate$taxSpendSelf$weights),
length(party_out_income_guarantee_separate$ideoBHPSJjobForAll$weights))
sink("../generated_tex/fe_by_party_by_treat.tex")
m1 <- party_out_income_guarantee_separate$redistSelf
m2 <- party_out_income_guarantee_separate$taxSpendSelf
m3 <- party_out_income_guarantee_separate$ideoBHPSJjobForAll
stargazer::stargazer(m1,m2,m3,
dep.var.labels.include = T,
dep.var.caption = "",
multicolumn = FALSE,
dep.var.labels = c("$redistSelf$", "$taxSpendSelf$", "$jobsForAll$"),
no.space = TRUE,
omit.stat = c("all"),
omit = c("^vote19Labour:as.factor",
"^vote19Other:as.factor"),
covariate.labels = c("$CovidLostEmployment$",
"$CovidFurlough$",
"$CovidSelfEmployment$",
"$CovidUniversalCredit$",
"$CovidFurlough * Labour$",
"$CovidFurlough * Other$",
"$CovidSelfEmployment * Labour$",
"$CovidSelfEmployment * Other$",
"$CovidUniversalCredit * Labour$",
"$CovidUniversalCredit * Other$"),
float = FALSE,
add.lines = list(c("N respondents", ns[,1]),
c("N waves", ns[,2]),
c("N obs.", n_obs),
c("Ind. FEs", "Yes", "Yes", "Yes"),
c("Wave FEs", "Yes", "Yes", "Yes")))
sink()
# 7. govtHandouts and reasonForUnemployment (Deservingness)
party_out_income_guarantee_separate_coefs %>%
filter(var %in% c("govtHandouts", "reasonForUnemployment")) %>%
mutate(var = factor(var, levels = outcome_vars)) %>%
ggplot(aes(y = var, x = estimate, xmin = lo, xmax = hi, col = levels, group = levels)) +
geom_point(position = position_dodge(width = .5)) +
geom_errorbarh(height = 0.0001, position = position_dodge(width = .5)) +
facet_wrap(~ treatment, ncol = 4) +
geom_vline(xintercept = 0, linetype = 1) +
xlim(c(-1,1)) +
theme_bw() +
scale_color_manual("Party", values = c("blue", "red", "gray")) +
xlab("Treatment effect") +
ylab("")
ggsave("../generated_images/fe_by_party_by_treat_deserving.pdf", width = 15, height = 5*.5)
## - prior position interaction spec = separating UC, furlough, self-employment
prior_out_income_guarantee_separate %>%
map(~ lapply(c("income_guarantee_covid_job_treatment", "income_guarantee_covid_self_treatment", "income_guarantee_other_treatment","lost_employment"),
function(v)
get_marginal_effects_interaction(v, interaction_levels = c("Left","Mid", "Right"), x = .x)) %>%
bind_rows) %>%
bind_rows(.id = "var") %>%
tibble() %>%
mutate(treatment = recode(treatment, "income_guarantee_covid_job_treatment" = "Furlough",
"income_guarantee_covid_self_treatment" = "Self-employment",
"income_guarantee_other_treatment" = "Universal Credit",
"lost_employment" = "Lost Employment")) %>%
ggplot(aes(x = estimate, xmin = lo, xmax = hi, y = var, col = levels, group = levels)) + geom_pointrange(position = position_dodge(.2)) + facet_wrap(~treatment) + theme_bw() + geom_vline(xintercept = 0, lty = 2)   +
ylab("") +
xlab("Conditional treatment effect") +
scale_color_manual("Prior attitude", values = c("orange", "darkgreen", "brown"))
ggsave("../generated_images/fe_by_prior_by_treat.pdf", width = 6, height = 4)
## - prior position interaction spec, w14 onwards = separating UC, furlough, self-employment
prior_out_income_guarantee_separate14 %>%
map(~ lapply(c("income_guarantee_covid_job_treatment", "income_guarantee_covid_self_treatment", "income_guarantee_other_treatment","lost_employment"),
function(v)
get_marginal_effects_interaction(v, interaction_levels = c("Left","Mid", "Right"), x = .x)) %>%
bind_rows) %>%
bind_rows(.id = "var") %>%
tibble() %>%
mutate(treatment = recode(treatment, "income_guarantee_covid_job_treatment" = "Furlough",
"income_guarantee_covid_self_treatment" = "Self-employment",
"income_guarantee_other_treatment" = "Universal Credit",
"lost_employment" = "Lost Employment")) %>%
ggplot(aes(x = estimate, xmin = lo, xmax = hi, y = var, col = levels, group = levels)) + geom_pointrange(position = position_dodge(.2)) + facet_wrap(~treatment) + theme_bw() + geom_vline(xintercept = 0, lty = 2)   +
ylab("") +
xlab("Conditional treatment effect") +
scale_color_manual("Prior attitude", values = c("orange", "darkgreen", "brown"))
ggsave("../generated_images/fe_by_prior_by_treat_w14onwards.pdf", width = 6, height = 4)
## - prior position interaction spec, most recent prior position = separating UC, furlough, self-employment
prior_out_income_guarantee_separate_recent %>%
map(~ lapply(c("income_guarantee_covid_job_treatment", "income_guarantee_covid_self_treatment", "income_guarantee_other_treatment","lost_employment"),
function(v)
get_marginal_effects_interaction(v, interaction_levels = c("Left","Mid", "Right"), x = .x)) %>%
bind_rows) %>%
bind_rows(.id = "var") %>%
tibble() %>%
mutate(treatment = recode(treatment, "income_guarantee_covid_job_treatment" = "Furlough",
"income_guarantee_covid_self_treatment" = "Self-employment",
"income_guarantee_other_treatment" = "Universal Credit",
"lost_employment" = "Lost Employment")) %>%
ggplot(aes(x = estimate, xmin = lo, xmax = hi, y = var, col = levels, group = levels)) + geom_pointrange(position = position_dodge(.2)) + facet_wrap(~treatment) + theme_bw() + geom_vline(xintercept = 0, lty = 2)   +
ylab("") +
xlab("Conditional treatment effect") +
scale_color_manual("Prior attitude", values = c("orange", "darkgreen", "brown"))
ggsave("../generated_images/fe_by_prior_by_treat_most_recent.pdf", width = 6, height = 4)
## - "don't know" prior position interaction spec = separating UC, furlough, self-employment
dk_out_income_guarantee_separate %>%
map(~ lapply(c("income_guarantee_covid_job_treatment", "income_guarantee_covid_self_treatment", "income_guarantee_other_treatment","lost_employment"),
function(v)
get_marginal_effects_interaction(v, interaction_levels = c("FALSE", "TRUE"), x = .x)) %>%
bind_rows) %>%
bind_rows(.id = "var") %>%
tibble() %>%
mutate(treatment = recode(treatment, "income_guarantee_covid_job_treatment" = "Furlough",
"income_guarantee_covid_self_treatment" = "Self-employment",
"income_guarantee_other_treatment" = "Universal Credit",
"lost_employment" = "Lost Employment")) %>%
ggplot(aes(x = estimate, xmin = lo, xmax = hi, y = var, col = levels, group = levels)) + geom_pointrange(position = position_dodge(.2)) + facet_wrap(~treatment) + theme_bw() + geom_vline(xintercept = 0, lty = 2)   +
ylab("") +
xlab("Conditional treatment effect") +
scale_color_manual("'Don't know' respondent", values = c("orange", "darkgreen"))
ggsave("../generated_images/fe_by_prior_dk_by_treat.pdf", width = 7.5, height = 5)
## - political attention interaction spec = separating UC, furlough, self-employment
attention_out_income_guarantee_separate %>%
map(~ lapply(c("income_guarantee_covid_job_treatment", "income_guarantee_covid_self_treatment", "income_guarantee_other_treatment","lost_employment"),
function(v)
get_marginal_effects_interaction(v, interaction_levels = c("Low", "High"), x = .x)) %>%
bind_rows) %>%
bind_rows(.id = "var") %>%
tibble() %>%
mutate(treatment = recode(treatment, "income_guarantee_covid_job_treatment" = "Furlough",
"income_guarantee_covid_self_treatment" = "Self-employment",
"income_guarantee_other_treatment" = "Universal Credit",
"lost_employment" = "Lost Employment")) %>%
ggplot(aes(x = estimate, xmin = lo, xmax = hi, y = var, col = levels, group = levels)) + geom_pointrange(position = position_dodge(.2)) + facet_wrap(~treatment) + theme_bw() + geom_vline(xintercept = 0, lty = 2)   +
ylab("") +
xlab("Conditional treatment effect") +
scale_color_manual("Political attention", values = c("orange", "darkgreen"))
ggsave("../generated_images/fe_by_attention_by_treat.pdf", width = 7.5, height = 5)
## - prior government support interaction spec = separating UC, furlough, self-employment
prior_gov_support_out_income_guarantee_separate %>%
map(~ lapply(c("income_guarantee_covid_job_treatment", "income_guarantee_covid_self_treatment", "income_guarantee_other_treatment","lost_employment"),
function(v)
get_marginal_effects_interaction(v, interaction_levels = c("No", "Yes"), x = .x)) %>%
bind_rows) %>%
bind_rows(.id = "var") %>%
tibble() %>%
mutate(treatment = recode(treatment, "income_guarantee_covid_job_treatment" = "Furlough",
"income_guarantee_covid_self_treatment" = "Self-employment",
"income_guarantee_other_treatment" = "Universal Credit",
"lost_employment" = "Lost Employment")) %>%
ggplot(aes(x = estimate, xmin = lo, xmax = hi, y = var, col = levels, group = levels)) + geom_pointrange(position = position_dodge(.2)) + facet_wrap(~treatment) + theme_bw() + geom_vline(xintercept = 0, lty = 2)   +
ylab("") +
xlab("Conditional treatment effect") +
scale_color_manual("Prior government support", values = c("orange", "darkgreen"))
#lapply(prior_gov_support_out_income_guarantee_separate, summary)
ggsave("../generated_images/fe_by_prior_gov_support_by_treat.pdf", width = 7.5, height = 5)
## - interacting lost_employment and universal credit receipt
# Table
sink("../generated_tex/fe_multi_treatment_employment_uc_interaction.tex")
m1 <- baseline_out_income_guarantee_separate_lost_employment_interaction$redistSelf
m2 <- baseline_out_income_guarantee_separate_lost_employment_interaction$taxSpendSelf
m3 <- baseline_out_income_guarantee_separate_lost_employment_interaction$ideoBHPSJjobForAll
m4 <- baseline_out_income_guarantee_separate_lost_employment_interaction$riskUnemployment
m5 <- baseline_out_income_guarantee_separate_lost_employment_interaction$riskPoverty
stargazer::stargazer(m1, m2, m3, m4, m5,
dep.var.labels.include = T,
dep.var.caption = "",
multicolumn = FALSE,
dep.var.labels = c("$redistSelf$", "$taxSpendSelf$", "$jobsForAll$", "$riskUnemployment$", "$riskPoverty$"),
no.space = TRUE,
omit.stat = c("all"),
covariate.labels = c("$LostEmployment$", "$UniversalCredit$", "$Furlough$", "$SelfEmployment$", "$LostEmployment \\cdot UC$"),
float = FALSE,
add.lines = list(c("Ind. FEs", "Yes", "Yes", "Yes", "Yes", "Yes"),
c("Wave FEs", "Yes", "Yes", "Yes", "Yes", "Yes")))
sink()
## #################
## Descriptives
# Outcome presence/absence by wave
outcome_vars <- c("redistSelf", "taxSpendSelf", "ideoBHPSJjobForAll", "riskUnemployment", "riskPoverty", "govtHandouts", "reasonForUnemployment")
mat <- matrix(NA, length(outcome_vars), length(unique(bes_long$wave)))
for(i in 1:length(outcome_vars)) mat[i,] <- !sapply(unique(bes_long$wave),function(x) all(is.na(bes_long[[outcome_vars[i]]][bes_long$wave == x])))
mat <- data.frame(mat)
rownames(mat) <- outcome_vars
names(mat) <- unique(bes_long$wave)
mat$id <- outcome_vars
mat <- melt(mat, id.var = "id")
mat <- data.table(mat)
x <- mat[,sum(value),by = id]
mat$id[mat$id == "ideoBHPSJjobForAll"] <- "jobsForAll"
x$id[x$id == "ideoBHPSJjobForAll"] <- "jobsForAll"
setkey(x, V1)
mat$id <- factor(mat$id, levels = x$id)
mat$value <- ifelse(mat$value, "...in wave", "...not in wave")
dv_by_wave <- ggplot(mat, aes(x = variable, y = id, col = value, fill = value)) + geom_tile() +
scale_color_manual("Question...",values = c(scales::alpha("black",.7), scales::alpha("black",.2))) +
scale_fill_manual("Question...",values = c(scales::alpha("black",.7), scales::alpha("black",.2))) +
theme_bw() +
theme(panel.grid = element_blank(), axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
scale_x_discrete(labels = c(paste0("BES ",1:19),"PACER 1", "BES 20","PACER 2","BES 21")) +
xlab("") + ylab("")
png("../generated_images/DV_by_wave.png", 2300, 1000, res=  300)
print(dv_by_wave)
dev.off()
# Raw outcome by wave
wave_dates <- as.Date(c("2014-02-20",
"2014-05-22",
"2014-09-19",
"2015-03-04",
"2015-03-31",
"2015-05-08",
"2016-04-14",
"2016-05-06",
"2016-06-24",
"2016-11-24",
"2017-04-24",
"2017-05-05",
"2017-06-09",
"2018-05-04",
"2019-03-11",
"2019-05-24",
"2019-11-01",
"2019-11-13",
"2019-12-13",
"2020-04-18",
"2020-06-03",
"2020-09-15",
"2021-05-08"))
wave_dates <- data.frame(wave = c(1:19,19.5, 20, 20.5, 21), wave_dates)
bes_long <- merge(bes_long, wave_dates, by = "wave")
out <- merge(out, wave_dates, by = "wave")
plot_by_wave <- function(var = "taxSpendSelf", title = "Support for redistribution by wave"){
title <- gsub("ideoBHPSJjobForAll", "jobsForAll", title)
for_plot <- bes_long %>%
mutate(outcome = as.numeric(get(var))) %>%
filter(!is.na(cross_sectional_weight_) & !is.na(outcome)) %>%
group_by(wave_dates) %>%
mutate(n = sum(!is.na(outcome))) %>%
filter(n != 1) %>%
ungroup() %>%
estimatr::lm_robust(outcome ~ as.factor(wave_dates) - 1, weights = cross_sectional_weight_, data = .) %>%
DeclareDesign::tidy() %>%
mutate(date = as.Date(gsub("as.factor\\(wave_dates\\)","",term))) %>%
filter(statistic != Inf) %>%
mutate(estimate_mean = mean(estimate),
estimate_sd = sd(estimate))
for_plot %>%
ggplot(aes(x = date, y = estimate, ymin = conf.low, ymax = conf.high)) +
geom_linerange() +
geom_line()  +
geom_point() +
theme_bw() +
theme(legend.position = "bottom",panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
scale_x_continuous(breaks = as.Date(paste0(2014:2021,"-01-01")), labels = 2014:2021, limits = range(c(bes_long$wave_dates, as.Date("2021-01-01"))))  +
geom_vline(xintercept = as.Date("2020-03-16"), lty = 2)+
scale_linetype("", guide = "none") +
scale_size("", guide = "none") +
ggtitle(title) + xlab("Wave") + ylab("")
}
plot_by_wave("redistSelf", "redistSelf") + ylim(c(6,7))
ggsave(paste0("../generated_images/fig1_redistSelf_by_wave.pdf"), width = 6, height = 3)
ggsave(paste0("../generated_images/fig1_redistSelf_by_wave.tiff"), width = 6, height = 3, dpi = 800)
plot_by_wave("taxSpendSelf", "taxSpendSelf") + ylim(c(6.75, 7.75))
ggsave(paste0("../generated_images/fig1_taxSpendSelf_by_wave.pdf"), width = 6, height = 3)
ggsave(paste0("../generated_images/fig1_taxSpendSelf_by_wave.tiff"), width = 6, height = 3, dpi = 800)
